import java.util.ArrayList;
import java.util.List;

public class Solution234 {
    public boolean isPalindrome(ListNode head) {
        List<Integer> s = new ArrayList<>();
        while (head != null) {
            s.add(head.val);
            head = head.next;
        }
        int i = 0, j = s.size() - 1;
        while (i < j) {
            if (s.get(i).equals(s.get(j))) {
                i++;
                j--;
            } else {
                return false;
            }
        }
        return true;
    }
}
